# include <bits/stdc++.h>
# define int long long

const int N=200010,INF=0x3f3f3f3f;

inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-') f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
int n,m,a,b;
typedef long long ll;
ll dis[N];

std::vector <int> G[N];

namespace Sub1{
	int dis[1010][1010];
	
	int djs[1010];
	bool c[1010];
	
	inline void bfs(int *d,int s){
		std::fill(d+1,d+1+n,INF),d[s]=0;
		std::queue <int> q;
		q.push(s);
		while(!q.empty()){
			int i=q.front();
			q.pop();
			for(auto j:G[i]) if(d[j]>d[i]+1) d[j]=d[i]+1,q.push(j);
		}
		return;
	}
	
	inline void dijkstra(void){
		memset(djs,INF,sizeof(djs));
		djs[1]=0;
		for(int i=1;i<=n;++i){
			int id=0;
			for(int j=1;j<=n;++j) if(!c[j]&&djs[j]<djs[id]) id=j;
			if(!id) break;
			c[id]=true;	
			for(int j=1;j<=n;++j){
				if(dis[id][j]==1&&djs[j]>djs[id]+a) djs[j]=std::min(djs[j],djs[id]+a);
				if(dis[id][j]==2&&djs[j]>djs[id]+b) djs[j]=std::min(djs[j],djs[id]+b);
			}
		}
		for(int i=2;i<=n;++i) printf("%lld\n",djs[i]);
		return;
	}
	
	inline void solve(void){
		for(int i=1;i<=n;++i) bfs(dis[i],i);		
		dijkstra();
		return;
	}
	
}

namespace Sub2{
	int dis[N];
	
	void dfs(int x,int fa){
		dis[x]=std::min(dis[x],dis[fa]+a);
		
//		std::cerr<<dis[x]<<std::endl;
		
		for(auto y:G[x]) if(y!=fa) dis[y]=std::min(dis[y],dis[fa]+b),dfs(y,x);
		return;
	}
	inline void solve(void){
		memset(dis,INF,sizeof(dis)),dis[1]=0;
		for(auto x:G[1]) dfs(x,1);
		for(int i=2;i<=n;++i) printf("%lld\n",dis[i]);
		return;
	}
}

signed main(void){
	freopen("edge.in","r",stdin);
	freopen("edge.out","w",stdout);
	
	n=read(),m=read(),a=read(),b=read();
	
	for(int i=1;i<=m;++i){
		int u=read(),v=read();
		G[u].push_back(v),G[v].push_back(u);
	}
	
	if(m<=1000) Sub1::solve();
	else if(m==n-1) Sub2::solve();

	
	return 0;
}